package com.edu.koudingmusic.activities;

import android.app.ActionBar;
import android.app.Activity;
import android.app.Application;
import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

import com.edu.koudingmusic.BaseApplication;
import com.edu.koudingmusic.MainActivity;
import com.edu.koudingmusic.R;
import com.edu.koudingmusic.services.PlayService;

public class SplashActivity extends Activity {


    private static final int START_ACTIVITY = 0x1;
    private Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what) {
                case START_ACTIVITY:
                    startActivity(new Intent(SplashActivity.this, MainActivity.class));
                    finish();
                    break;
            }
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        // 启动服务
        Intent intent = new Intent(this, PlayService.class);
        startService(intent);
        mHandler.sendEmptyMessageDelayed(START_ACTIVITY, 3000);
    }
}
